﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Agenda;


namespace AgendaForms
{
    public partial class FrmContactos : Form,IObserver
    {
        public FrmContactos()
        {
            InitializeComponent();
            cargarListaContactos();

        }  

        public void Update(Observable obs)
        {
            this.lstContactos.Items.Clear();
            cargarListaContactos();

        }

        public void cargarListaContactos()
        {
            foreach (Contacto c in AgendaSist.GetInstance().ListaDeContactos)
            {
                this.lstContactos.Items.Add(c.Nombre);
            }
        }

        private void FrmContactos_Load(object sender, EventArgs e)
        {
            AgendaSist.GetInstance().ListaObervers.Add(this);
        }
    }
}
